/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package vn.edu.hcmus.fit.se.mdd.mbuid.cfcui.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;

import vn.edu.hcmus.fit.se.mdd.mbuid.cfcui.AnchorType;
import vn.edu.hcmus.fit.se.mdd.mbuid.cfcui.CfcuiPackage;
import vn.edu.hcmus.fit.se.mdd.mbuid.cfcui.DockType;
import vn.edu.hcmus.fit.se.mdd.mbuid.cfcui.UIComponent;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>UI Component</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link vn.edu.hcmus.fit.se.mdd.mbuid.cfcui.impl.UIComponentImpl#getAnchor <em>Anchor</em>}</li>
 *   <li>{@link vn.edu.hcmus.fit.se.mdd.mbuid.cfcui.impl.UIComponentImpl#getDock <em>Dock</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class UIComponentImpl extends PresentationComponentImpl implements UIComponent {
	/**
	 * The cached value of the '{@link #getAnchor() <em>Anchor</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAnchor()
	 * @generated
	 * @ordered
	 */
	protected EList<AnchorType> anchor;

	/**
	 * The default value of the '{@link #getDock() <em>Dock</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDock()
	 * @generated
	 * @ordered
	 */
	protected static final DockType DOCK_EDEFAULT = DockType.NONE;

	/**
	 * The cached value of the '{@link #getDock() <em>Dock</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDock()
	 * @generated
	 * @ordered
	 */
	protected DockType dock = DOCK_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UIComponentImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CfcuiPackage.Literals.UI_COMPONENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<AnchorType> getAnchor() {
		if (anchor == null) {
			anchor = new EDataTypeUniqueEList<AnchorType>(AnchorType.class, this, CfcuiPackage.UI_COMPONENT__ANCHOR);
		}
		return anchor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DockType getDock() {
		return dock;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDock(DockType newDock) {
		DockType oldDock = dock;
		dock = newDock == null ? DOCK_EDEFAULT : newDock;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CfcuiPackage.UI_COMPONENT__DOCK, oldDock, dock));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case CfcuiPackage.UI_COMPONENT__ANCHOR:
				return getAnchor();
			case CfcuiPackage.UI_COMPONENT__DOCK:
				return getDock();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case CfcuiPackage.UI_COMPONENT__ANCHOR:
				getAnchor().clear();
				getAnchor().addAll((Collection<? extends AnchorType>)newValue);
				return;
			case CfcuiPackage.UI_COMPONENT__DOCK:
				setDock((DockType)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case CfcuiPackage.UI_COMPONENT__ANCHOR:
				getAnchor().clear();
				return;
			case CfcuiPackage.UI_COMPONENT__DOCK:
				setDock(DOCK_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case CfcuiPackage.UI_COMPONENT__ANCHOR:
				return anchor != null && !anchor.isEmpty();
			case CfcuiPackage.UI_COMPONENT__DOCK:
				return dock != DOCK_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (anchor: ");
		result.append(anchor);
		result.append(", dock: ");
		result.append(dock);
		result.append(')');
		return result.toString();
	}

} //UIComponentImpl
